<template>
	<view>
		<view class="cover-img">
			<view class="">
				<image class="upload-img" src="../../static/my/upload.png" mode=""></image>
				<view class="">我的封面照片</view>
			</view>
			
			<image v-if="0" class="cover" src="../../static/img-6.png" mode="aspectFill"></image>
		</view>
		<view class="infos">
			<view class="title">基本信息</view>
			<view class="name-id">
				<view class="each">
					<view class="name">姓名 <text>*</text> </view>
					<view class="z-flex">
						<input type="text" placeholder="请输入" />
					</view>
				</view>
				<view style="height: 24rpx;width: 1rpx;"></view>
				<view class="each">
					<view class="name">身份证号 <text>*</text> </view>
					<view class="z-flex">
						<input type="text" placeholder="请输入" />
					</view>
				</view>
			</view>
			
			<view class="title">上传照片 <text>（上传3张以上个人生活照，其他一律不通过）</text> </view>
			<view class="upload">
				<u-upload width="77" height="77" :fileList="fileList1" @afterRead="afterRead" @delete="deletePic" name="1"
					multiple :maxCount="6">
					<image src="../../static/my/upload.png" mode="widthFix" style="width: 154rpx;height: 154rpx;">
					</image>
				</u-upload>
			</view>
			
			<view class="title">服务类型</view>
			<view class="name-id">
				<view class="each">
					<view class="name">台球 </view>
					<view class="z-flex color">
						<input type="text" v-model="billiards" placeholder="请输入" /> <text class="unit">元/时</text>
					</view>
				</view>
				<view style="height: 24rpx;width: 1rpx;"></view>
				<view class="each">
					<view class="name">麻将 </view>
					<view class="z-flex color">
						<input type="text" v-model="mahjong" placeholder="请输入" /> <text class="unit">元/时</text>
					</view>
				</view>
			</view>
			
			<view class="title">基本信息</view>
			<view class="name-id">
				<view class="each">
					<view class="name">昵称 <text>*</text> </view>
					<view class="z-flex">
						<input type="text" placeholder="请输入" />
					</view>
				</view>
				<view style="height: 24rpx;width: 1rpx;"></view>
				<view class="each">
					<view class="name">性别 <text>*</text> </view>
					<view class="z-flex">
						<input type="text" disabled placeholder="请选择" />
						<image src="../../static/my/select-r.png" mode=""></image>
					</view>
				</view>
				<view style="height: 24rpx;width: 1rpx;"></view>
				<view class="each">
					<view class="name">身高 <text>*</text> </view>
					<view class="z-flex">
						<input type="text" disabled placeholder="请选择" />
						<image src="../../static/my/select-r.png" mode=""></image>
					</view>
				</view>
				<view style="height: 24rpx;width: 1rpx;"></view>
				<view class="each">
					<view class="name">体重 <text>*</text> </view>
					<view class="z-flex">
						<input type="text" disabled placeholder="请选择" />
						<image src="../../static/my/select-r.png" mode=""></image>
					</view>
				</view>
				<view style="height: 24rpx;width: 1rpx;"></view>
				<view class="each">
					<view class="name">职业 <text>*</text> </view>
					<view class="z-flex">
						<input type="text" disabled placeholder="请选择" />
						<image src="../../static/my/select-r.png" mode=""></image>
					</view>
				</view>
				<view style="height: 24rpx;width: 1rpx;"></view>
				<view class="each">
					<view class="name">生日 <text>*</text> </view>
					<view class="z-flex">
						<input type="text" disabled placeholder="请选择" />
						<image src="../../static/my/select-r.png" mode=""></image>
					</view>
				</view>
			</view>
			
			<view class="title">联系方式</view>
			<view class="name-id">
				<view class="each">
					<view class="name">微信号 <text>*</text> </view>
					<view class="z-flex">
						<input type="text" placeholder="请输入" />
					</view>
				</view>
				<view style="height: 24rpx;width: 1rpx;"></view>
				<view class="each">
					<view class="name">手机号 <text>*</text> </view>
					<view class="z-flex">
						<input type="number" placeholder="请输入" />
					</view>
				</view>
				<view style="height: 24rpx;width: 1rpx;"></view>
				<view class="each">
					<view class="name">门店名称 <text>*</text> </view>
					<view class="z-flex">
						<input type="text" disabled placeholder="请选择" />
						<image src="../../static/my/select-r.png" mode=""></image>
					</view>
				</view>
				<view style="height: 24rpx;width: 1rpx;"></view>
				<view class="each">
					<view class="name">默认地址 <text>*</text> </view>
					<view class="z-flex">
						<input type="text" placeholder="请输入" />
					</view>
				</view>
			</view>
			
			
			<view class="title2"> <view class="">我的标签<text>*</text></view> <image src="../../static/my/select-r.png" mode=""></image> </view>
			<view class="tabs">
				<view class="tab">台球🎱😂</view>
			</view>
			
			<view class="title">爱好</view>
			<view class="describe">
				<textarea placeholder="请输入" name="" id="" cols="30" rows="10"></textarea>
			</view>
			
			<view class="title">个人介绍</view>
			<view class="describe">
				<textarea placeholder="请输入" name="" id="" cols="30" rows="10"></textarea>
			</view>
			
			<view class="agreement"> <image src="../../static/login/choose.png" mode=""></image>点击表示您已阅读并同意 <text>《入驻用户规则》</text> </view>
			<view style="height: 180rpx; width: 1rpx"></view>
		</view>
		
		
		<view class="btn-box">
			<view class="PlaceAnOrder-btn" @click="">提交</view>
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				fileList1: [],
				billiards:0,
				mahjong:0
			}
		},
		methods: {
			// 图片处理
			deletePic(event) {
				this[`fileList${event.name}`].splice(event.index, 1)
			},
			// 新增图片
			async afterRead(event) {
				// 当设置 mutiple 为 true 时, file 为数组格式，否则为对象格式
			
				let lists = [].concat(event.file)
				// console.log(lists)
				let fileListLen = this[`fileList${event.name}`].length
				lists.map((item) => {
					this[`fileList${event.name}`].push({
						...item,
						status: 'uploading',
						message: '上传中'
					})
				})
			
				for (let i = 0; i < lists.length; i++) {
					const result = await this.uploadFilePromise(lists[i].url)
					if (result) {
						let item = this[`fileList${event.name}`][fileListLen]
						this[`fileList${event.name}`].splice(fileListLen, 1, Object.assign(item, {
							status: 'success',
							message: '',
							url: this.$oss(result),
							ful: result
						}))
						fileListLen++
					} else {
						this[`fileList${event.name}`].splice(fileListLen, 1)
					}
			
				}
			},
			uploadFilePromise(url) {
				let that = this
				return new Promise((resolve, reject) => {
					let a = uni.uploadFile({
						url: that.$uploadUrl, // 仅为示例，非真实的接口地址
						filePath: url,
						name: 'file',
						formData: {
							type: 'image',
							token: uni.getStorageSync('token')
						},
						success: (res) => {
							let data = JSON.parse(res.data)
							if (res.statusCode === 200 && data.code === 1 && data.data) {
								resolve(
									data.data.url
								)
							} else {
								resolve()
							}
						}
					});
				})
			},
		}
	}
</script>

<style lang="scss">
	page {
		background: #F7F8FA;
	}
	.cover-img {
		width: 750rpx;
		height: 680rpx;
		background: #F7F8FA;
		text-align: center;
		font-weight: 500;
		font-size: 26rpx;
		color: #A4A9B7;
		.upload-img {
			width: 150rpx;
			height: 150rpx;
			margin-top: 120rpx;
		}
		
		.cover {
			width: 100%;
			height: 100%;
		}
	}
	.infos {
		width: 750rpx;
		background: #FFFFFF;
		border-radius: 40rpx 40rpx 40rpx 40rpx;
		position: relative;
		top: -40rpx;
		
		.title {
			font-weight: bold;
			font-size: 30rpx;
			color: #1C274C;
			padding: 40rpx 0 0 32rpx;
			text {
				font-weight: 500;
				font-size: 22rpx;
				color: #A4A9B7;
			}
		}
		.title2 {
			font-weight: bold;
			font-size: 30rpx;
			color: #1C274C;
			padding: 40rpx 32rpx 0 32rpx;
			display: flex;
			justify-content: space-between;
			image {
				width: 30rpx;
				height: 30rpx;
			}
			text {
				color: red;
			}
		}
		
		.name-id {
			width: 622rpx;
			padding: 32rpx;
			margin: auto;
			background: #F7F8FA;
			border-radius: 40rpx 40rpx 40rpx 40rpx;
			margin-top: 24rpx;
			
			.each {
				width: 558rpx;
				padding: 34rpx 32rpx;
				// height: 106rpx;
				background: #FFFFFF;
				border-radius: 20rpx 20rpx 20rpx 20rpx;
				margin: auto;
				display: flex;
				justify-content: space-between;
				align-items: center;
				.name {
					font-weight: bold;
					font-size: 28rpx;
					color: #1c274c;
					text {
						color: red;
					}
				}
				input {
					font-size: 28rpx;
					text-align: right;
					width: 400rpx;
				}
				image {
					width: 30rpx;
					height: 30rpx;
				}
				.color {
					color: #FF7B18;
				}
				.unit {
					font-weight: 500;
					font-size: 28rpx;
					color: #1C274C;
				}
			}
		}
		
		.tabs {
			padding: 0 32rpx;
			.tab {
				display: inline-block;
				margin-top: 24rpx;
				padding: 0 32rpx;
				height: 72rpx;
				line-height: 72rpx;
				border-radius: 41rpx 41rpx 41rpx 41rpx;
				border: 1rpx solid #edeef1;
				font-weight: 500;
				font-size: 28rpx;
				color: #6b738b;
				margin-right: 24rpx;
			}
			.cheTab {
				border: 1rpx solid #4BC264;
			}
		}
		
		.describe {
			width: 622rpx;
			height: 132rpx;
			background: #F7F8FA;
			border-radius: 20rpx 20rpx 20rpx 20rpx;
			margin: auto;
			padding: 32rpx;
			margin-top: 24rpx;
			textarea {
				height: 132rpx;
			}
		}
		
		
		.upload {
			margin: 32rpx 30rpx 0 30rpx;
		}
		
		.agreement {
			padding: 0 32rpx;
			image {
				width: 32rpx;
				height: 32rpx;
				vertical-align: middle;
				margin-right: 16rpx;
			}
			font-weight: 500;
			font-size: 26rpx;
			color: #A4A9B7;
			margin-top: 32rpx;
			text {
				color: #4BC264;
			}
		}
	}
	
	
	.btn-box {
		width: 100%;
		position: fixed;
		bottom: 40rpx;
		z-index: 9;
		.PlaceAnOrder-btn {
			width: 686rpx;
			height: 106rpx;
			margin: auto;
			background: #4bc264;
			border-radius: 20rpx 20rpx 20rpx 20rpx;
			font-weight: 800;
			font-size: 34rpx;
			color: #ffffff;
			line-height: 106rpx;
			text-align: center;
		}
	}
</style>
